LD	L,A
	LD	A,(DE)
	AND	#F0
	OR	L
	LD	(BC),A
	INC	DE
	INC	B
	DEC	H
	JR	NZ,L7069
	RET
L7078	POP	AF
	JR	NC,L708A
L707B	LD	A,(BC)
	AND	#F0
	LD	L,A
	LD	A,(DE)
	AND	#0F
	OR	L
	LD	(BC),A
	INC	DE
	INC	B
	DEC	H
	JR	NZ,L707B
	RET
L708A	LD	A,(BC)
	AND	#F0
	LD	L,A
	LD	A,(DE)
	AND	#F0
	RLC	A
	RLC	A
	RLC	A
	RLC	A
	OR	L
	LD	(BC),A
	INC	DE
	INC	B
	DEC	H
	JR	NZ,L708A
	RET
;
TTY_X	DEFB	#17
TTY_Y	DEFB	#10
;
KBD	PUSH	HL
	PUSH	DE
	PUSH	BC
	PUSH	IX
	LD	A,23
	LD	(SCROLL_CNT),A
	LD	A,(IX+CSRX)
	LD	HL,TTY_X
	LD	(HL),A
	LD	A,(IX+CSRY)
	INC	HL
	LD	(HL),A
	CALL	L7100
	RES	5,(IY+1)
	EI
KBDWT	BIT	5,(IY+1)
	JR	Z,KBDWT
	LD	A,(IY-50)
	RES	5,(IY+1)
	EX	AF,AF'
	CALL	L7100
	LD	HL,#001E
	LD	DE,#001E
	CALL	#03B5
	EX	AF,AF'
	CALL	L7112
	POP	IX
	POP	BC
	POP	DE
	POP	HL
	RET
;
L7100	CALL	L7018
	LD	A,#F0
	JR	NC,L7109
	LD	A,#0F
L7109	LD	C,A
	LD	B,8
SCURL	LD	A,(HL)
	XOR	C
	LD	(HL),A
	INC	H
	DJNZ	SCURL
	RET
;
L7112	CP	#41
	RET	C
	CP	#5B
	JR	NC,L711C
	ADD	A,#20
	RET
L711C	CP	#61
	RET	C
	CP	#7B
	JR	NC,L7126
	SUB	#20
	RET
L7126	LD	HL,L7133
L7129	CP	(HL)
	JR	Z,L7130
	INC	HL
	INC	HL
	JR	L7129
L7130	INC	HL
	LD	A,(HL)
	RET
L7133	DEFB	#E2,"~",#C3
	DEFB	"|",#CC,"{"
	DEFB	#CB,"}",#C6
	DEFB	"[",#C5,"]"
	DEFB	#C7,#C7,#C9
	DEFB	#C9,#C8,#C8
	DEFB	#CD,"\",#AC
	DEFB	#AC
;
CH_MODE	DEFB	#FF
;
DATA	EQU	$
CSRX	EQU	$-DATA
	DEFB	0
CSRY	EQU	$-DATA
	DEFB	0
;
TXT_600	DEFB	"600 "
TXT_1200 DEFB	"1200"
TXT_ODD	DEFB	"ODD "
TXT_EVEN DEFB	"EVEN"
TXT_DISC DEFB	"DISC	"
TXT_MEMORY DEFB	"MEMORY	"
TXT_SCREEN DEFB	"SCREEN	"
TXT_PRINTER DEFB "PRINTER"
BUFDEC	DEFS	6
BUFER_SCR DEFS 64
;
BAUD600	LD	A,#02		;wybor 600
	LD	(LFC8E),A
	LD	A,#04
	LD	(LFCA3),A
	LD	A,#02
	LD	(LFBED),A
	LD	A,#F5
	LD	(LFBF4),A
	LD	A,#81
	LD	(LFC00),A
	LD	A,#CD
	LD	(LFBFA),A
	LD	(LFC06),A
	LD	A,#B9
	LD	(LFC0C),A
	LD	A,#96
	LD	(CH_BAUD),A
	RET
;
BAUD1200
	LD	A,#01		;wybor 1200
	LD	(LFC8E),A
	LD	A,#02
	LD	(LFCA3),A
	LD	A,#01
	LD	(LFBED),A
	LD	A,#14
	LD	(LFBF4),A
	LD	A,#46
	LD	(LFC00),A
	LD	A,#3A
	LD	(LFBFA),A
	LD	(LFC06),A
	LD	A,#7D
	LD	(LFC0C),A
	LD	A,#1E
	LD	(CH_BAUD),A
	RET
;
PARODD	LD	A,#E4		;wybor ODD
	LD	(LFC71),A
	LD	A,#EC
	LD	(LFC74),A
	LD	A,#EA
	LD	(LFBD6),A
	LD	A,#E2
	LD	(LFBDD),A
	LD	A,#0A
	LD	(CH_PAR),A
	RET
;
PAREVEN
	LD	A,#E4		;wybor EVEN
	LD	(LFC74),A
	LD	A,#EC
	LD	(LFC71),A
	LD	A,#EA
	LD	(LFBDD),A
	LD	A,#E2
	LD	(LFBD6),A
	LD	A,#09
	LD	(CH_PAR),A
	RET
;
;	---- RECEIVE ----
;
RECEIVE
	XOR	A
	OUT	(#FE),A
	DI		;w HL -	s kakogo adresa	prinimatx
	LD	B,#00
	CALL	LFB55	;lowit piloton
	CALL	LFB64
;HL=skolxko prinql
;BC=skolxko o}ibok
	LD	A,7
	OUT	(#FE),A
	AND	A
	RET
;
;
LFB4B	PUSH	BC	;opros probela
	LD	BC,#7FFE
	IN	A,(C)
	BIT	0,A
	POP	BC
	RET
;
LFB55	CALL	LFB4B	;Opros SPACE
	RET	Z
	IN	A,(PORT)
	AND	#80
	CP	E
	JR	Z,LFB55
	LD	E,A
	DJNZ	LFB55
	RET		;wyhod esli byl	pilot ili signal
;
;w HL -	s kakogo adresa	priem
;
LFB64	PUSH	IX
	PUSH	IY
	PUSH	HL
	POP	IX
	LD	IY,#0000
LFB6F	PUSH	HL
	LD	HL,#0000     ;LEN
	LD	BC,#0000     ;ERRORS
LFB76	LD	D,#80
	IN	A,(PORT)
	AND	#80
LFB7C	LD	E,A
	LD	B,#00
LFB7F	IN	A,(PORT)
	AND	#80
	CP	E
	JR	NZ,LFB97
	DJNZ	LFB7F
	POP	HL
	PUSH	IY
	POP	BC
	PUSH	IX
	POP	DE
	POP	IY
	POP	IX
	SBC	HL,DE
	EI
	RET
;
LFB97	SLA	D
	JP	C,LFB7C
	LD	A,#E9
	CP	B
	JP	P,LFBAF
	XOR	A
	CP	C
	JP	NZ,LFBC4
	LD	C,#01
	CALL	LFBEC
	JP	LFB76
;
LFBAF	XOR	A
	CP	C
	JP	Z,LFB76
	INC	HL
	CALL	LFBF8
	LD	A,#09
	CP	L
	JP	Z,LFBD4
	SCF
	RR	H
	JP	LFB76
;
LFBC4	INC	HL
	CALL	LFC04
	LD	A,#09
	CP	L
	JP	Z,LFBDB
	AND	A
	RR	H
	JP	LFB76
;
LFBD4	XOR	A
	OR	H
LFBD6	JP	PE,LFBE2
	JR	LFBE8
;
LFBDB	XOR	A
	OR	H
LFBDD	JP	PO,LFBE2
	JR	LFBE8
;
LFBE2	POP	HL
	LD	(HL),A
	INC	HL
	JP	LFB6F
;
LFBE8	INC	IY
	JR	LFBE2
;
LFBEC	LD	B,#01
LFBED	EQU	$-1
LFBEE	CALL	LFC10
	DJNZ	LFBEE
	LD	B,#14
LFBF4	EQU	$-1
LFBF5	DJNZ	LFBF5
